<template>
    <div>
        <!--帐号信息搜索  -->
        <template>
            <el-form :inline="true" :model="accountSearchForm" :rules="accountSearchFormRules"  ref="accountSearchFormRules">
                <el-row>
                    <el-col :span="22">
                        
                        <el-form-item label="登录帐号">
                            <el-input v-model="accountSearchForm.id"></el-input>
                        </el-form-item>

                        <el-form-item label="昵称">
                            <el-input v-model="accountSearchForm.nickname"></el-input>
                        </el-form-item>
                        <el-form-item label="名称">
                            <el-input v-model="accountSearchForm.name"></el-input>
                        </el-form-item>
                        <el-form-item label="手机" prop="mobile">
                            <el-input v-model="accountSearchForm.mobile"></el-input>
                        </el-form-item>

                        <el-form-item label="帐号状态">
                            <el-select v-model="accountSearchForm.status" placeholder="请选择">
                                <el-option label=" " value=""></el-option>
                                <el-option label="正常" value="1"></el-option>
                                <el-option label="锁定" value="2"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="2" class="text-right">
                        <el-form-item>
                            <el-button type="primary"  @click="fetchData(accountSearchForm)">查询</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </template>
        <!--帐号信息列表  -->
        <template>
            <el-table v-loading.body="loading" :data="accountList" border row-class-name="tableRow" height="364">
                <el-table-column show-overflow-tooltip prop="id" label="登录帐号" >
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="nickname" label="昵称">
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="name" label="名称" >
                    <template scope="scope">
                        <span class="color02 pointer" @click='certificationDetail(scope.$index, accountList)'>
                            {{scope.row.name}}
                        </span>
                    </template>
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="type" label="开通身份">
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="mobile" label="联系电话">
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="status" label="帐号状态">
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="registrationTime" label="注册时间">
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="lastLoginTime" label="上次登录">
                </el-table-column>
                <el-table-column show-overflow-tooltip label="操作">
                     <template scope="scope">
                         <el-dropdown trigger="click">
                           <div class="more-menu">
                           </div>
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item  @click.native.prevent='changelock(scope.$index, accountList)'>锁定/解锁</el-dropdown-item>
                                <el-dropdown-item  @click.native.prevent='changeMobile(scope.$index, accountList)'>手机号变更</el-dropdown-item>
                                <el-dropdown-item  @click.native.prevent='changePassword(scope.$index, accountList)'>登录密码重置</el-dropdown-item>
                                <el-dropdown-item  @click.native.prevent='operationLog(scope.$index, accountList)'>操作记录</el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                    </template>
                </el-table-column>
            </el-table>
        </template>
        <template>
            <div class="pagination-wrapper clearfix mt-10" v-if = "pagination.totalPage>1">
                <div class="fr font-14">
                    <span class="page-num mr-25">
                        总数：<span v-text="pagination.totalCount"></span> 每页显示 <span v-text="pagination.pageSize"></span>  条 共 <span v-text="pagination.totalPage"></span> 页
                    </span>
                    <el-pagination @current-change="changePage" :current-page="pagination.currentPage" :page-size="pagination.pageSize" layout="prev, pager, next" :total="pagination.totalCount" class="fr">
                    </el-pagination>
                </div>
            </div>
        </template>
        <!--锁定操作  -->
        <template>
            <el-dialog title="账号锁定与解锁" :visible.sync="changeLockDialogStatus" @close="closeDialog('changeLockForm')">
                <div>
                    <el-row>
                        <el-col :span="8">
                            <span> 账号昵称：<span v-text="activeDialogData.nickname"></span></span>
                        </el-col>
                         <el-col :span="8">
                            <span> 帐号ID：<span v-text="activeDialogData.id"></span></span>
                         </el-col>
                    </el-row>
                </div>
                <el-form :model="changeLockForm" :rules="changeLockFormRules"  ref="changeLockForm" class="mt-15">

                    <el-form-item label="帐号状态">
                        <el-switch @input="changeLockForm.isLock=!changeLockForm.isLock" :value="!changeLockForm.isLock" on-color="#13ce66" off-color="#ff4949">
                        </el-switch>
                    </el-form-item>
                       <el-form-item label="变更原因" prop="reason">
                        <el-input v-model="changeLockForm.reason" type="textarea" auto-complete="off"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="changeLockDialogStatus = false">取 消</el-button>
                    <el-button type="primary" @click="changelockSubmit('changeLockForm')">确 定</el-button>
                </div>
            </el-dialog>
        </template>
        <!--手机号变更  -->
        <template>
            <el-dialog title="手机号变更" :visible.sync="changeMobileDialogStatus" @close="closeDialog('changeMobileForm')">
                <div>
                    <el-row>
                        <el-col :span="8">
                            <span> 账号昵称：<span v-text="activeDialogData.nickname"></span></span>
                        </el-col>
                        <el-col :span="8">
                            <span> 帐号ID：<span v-text="activeDialogData.id"></span></span>
                        </el-col>
                        <el-col :span="8">
                             <span> 手机号码：<span v-text="activeDialogData.mobile"></span></span>
                        </el-col>
                    </el-row>
                </div>
                <el-form :model="changeMobileForm" :rules="changeMobileFormRules"  ref="changeMobileForm" class="mt-15">
                    <el-form-item label="新手机号码" prop="mobile">
                        <el-input v-model="changeMobileForm.mobile" auto-complete="off" ></el-input>
                    </el-form-item>
                       <el-form-item label="变更原因" prop="reason">
                        <el-input v-model="changeMobileForm.reason" type="textarea" auto-complete="off" placeholder="最多100个汉字"></el-input>
                    </el-form-item>
                    <span>提醒：手机号码变更成功后，会向用户新手机号发送手机号变更提醒</span>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="changeMobileDialogStatus = false">取 消</el-button>
                    <el-button type="primary" @click="changeMobileSubmit('changeMobileForm')">确 定</el-button>
                </div>
            </el-dialog>
        </template>
          <!-- 密码重置 -->
        <template>
            <el-dialog title="密码重置" :visible.sync="changePasswordDialogStatus" @close="closeDialog('changePasswordForm')">
                <div>
                    <el-row>
                        <el-col :span="8">
                            <span> 账号昵称：<span v-text="activeDialogData.nickname"></span></span>
                        </el-col>
                        <el-col :span="8">
                            <span> 帐号ID：<span v-text="activeDialogData.id"></span></span>
                        </el-col>
                        <el-col :span="8">
                        </el-col>
                    </el-row>
                </div>
                <el-form :model="changePasswordForm" :rules="changePasswordFormRules"  ref="changePasswordForm" class="mt-15">
                    <el-form-item label="新密码" prop="password">
                        <el-input v-model="changePasswordForm.password" type="password" auto-complete="off" placeholder="最多20个字符"></el-input>
                    </el-form-item>
                       <el-form-item label="变更原因" prop="reason">
                        <el-input v-model="changePasswordForm.reason" type="textarea" auto-complete="off" placeholder="最多100个汉字"></el-input>
                    </el-form-item>
                    <span>提醒：密码重置后，会向用户绑定手机号或邮箱中发送密码重置提醒</span>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="changePasswordDialogStatus = false">取 消</el-button>
                    <el-button type="primary" @click="changePasswordSubmit('changePasswordForm')">确 定</el-button>
                </div>
            </el-dialog>
        </template>
        <!-- 登录记录 -->
        <template>
            <el-dialog title="操作记录查看" size="large"  :visible.sync="operationLogDialogStatus">
                <!--操作日志查询  -->
                <template>
                    <el-form :inline="true" :model="operationLogForm">
                        <el-form-item label="操作人">
                            <el-input v-model="operationLogForm.operatorName"></el-input>
                        </el-form-item>
                        <el-form-item label="操作时间">
                            <el-date-picker v-model="operationLogForm.dateStart" type="date" placeholder="选择日期">
                            </el-date-picker>
                            <el-date-picker v-model="operationLogForm.dateEnd" type="date" placeholder="选择日期" >
                            </el-date-picker>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="fetchoperationLog(operationLogForm)">查询</el-button>
                        </el-form-item>
                    </el-form>
                </template>
                <!--操作日志列表  -->
                <template>
                    <el-table v-loading.body="loadingLog" :data="operationLogList" border style="width: 100%" class="text-center">
                        <el-table-column show-overflow-tooltip prop="operatorName" label="操作人">
                        </el-table-column>
                        <el-table-column show-overflow-tooltip prop="createdAt" label="操作时间">
                        </el-table-column>
                        <el-table-column show-overflow-tooltip prop="client" label="客户端">
                        </el-table-column>
                        <el-table-column show-overflow-tooltip prop="title" label="操作主题">
                        </el-table-column>
                        <el-table-column show-overflow-tooltip prop="result" label="操作结果">
                        </el-table-column>
                        <el-table-column show-overflow-tooltip prop="content" label="操作内容">
                        </el-table-column>
                    </el-table>
                </template>
                <div class="pagination-wrapper clearfix" v-if = "operationLogPagination.totalPage>1">
                    <el-pagination @current-change="changeLogPage" class="mt-15 ml-05 fr font-14" :current-page="operationLogPagination.currentPage" :page-size="operationLogPagination.pageSize" layout="prev, pager, next" :total="operationLogPagination.totalCount">
                    </el-pagination>
                </div>
                <div class="mt-20 text-right">
                    <el-button @click="operationLogDialogStatus = false" class="mt-15"> 关闭</el-button>
                </div>
            </el-dialog>
        </template>
        <!-- 查看企业详情/个人详情 -->
        <template>
            <el-dialog title="查看详情" size="large" :visible.sync="certificationDetailDialogStatus">
                <div class="pos-rel">
                    <el-popover
                        ref="popover4"
                        placement="right"
                        width="400"
                        trigger="click">
                        <el-row class="border-b1">
                        <h3>公司基本信息</h3>
                        </el-row>
                        <el-row class="mt-10">
                            <el-col :span="12">
                                    <el-row>中文名称：北京进击科技有限公司</el-row>
                                    <el-row>详细地址：北京市昌平区回龙观86号院</el-row>
                                    <el-row>注册资本：100 万元</el-row>
                                    <el-row>法定代表人：卢凯顺</el-row>
                                    <el-row>统一社会信用码：91330101MA27Y7GK78</el-row>
                            </el-col>
                            <el-col :span="12">
                                    <el-row>英文名称：abc</el-row>
                                    <el-row>公司网站：example@163.com</el-row>
                                    <el-row>公司规模：0-10人</el-row>
                                    <el-row>联系电话：010-87818352</el-row>
                                    <el-row>联系邮箱：example@163.com</el-row>
                            </el-col>
                        </el-row>
                    </el-popover>
                    <el-row>
                        <el-col :span="4">
                            <img src="https://dummyimage.com/95x95/f94242&text=#0011ff" alt="">
                        </el-col>
                        <el-col :span="20">
                            <el-row >
                                <el-col :span="6">用户编号：10080</el-col>
                                <el-col :span="6">昵称：破晓的清晨</el-col>
                                <el-col :span="6">用户等级：VIP</el-col>
                                <el-col :span="6">账号状态：正常</el-col>
                            </el-row>
                            <el-row class="mt-10">
                                <el-col :span="6" >
                                    <div  v-popover:popover4>认证状态：已认证(企业)</div>
                                </el-col>
                                <el-col :span="6">接发类型：接、发</el-col>
                                <el-col :span="6">积分等级：Lv 7</el-col>
                                <el-col :span="6">经验值：7000 分</el-col>
                            </el-row>
                            <el-row class="mt-10">
                                <el-col :span="6">注册渠道：手机/微博</el-col>
                                <el-col :span="8">注册时间：2016-10-08 10:54</el-col>
                                <el-col :span="8">最后登录时间：2016-10-08 10:54</el-col>
                            </el-row>
                        </el-col>
                    </el-row>
                    <el-row class="mt-15">
                        <el-col :span="12">
                            <el-row><h3>发包信息总览</h3></el-row>
                                <el-row class="mt-15">
                                    <el-col :span="8">信用值：100</el-col>
                                    <el-col :span="8">好评率：80%</el-col>
                                    <el-col :span="8">能力评估：优</el-col>
                                </el-row>
                                <el-row class="mt-05">
                                    <el-col :span="8">总发包数：10 个</el-col>
                                    <el-col :span="8">好评率：80%</el-col>
                                    <el-col :span="8">能力评估：优</el-col>
                                </el-row>
                                <el-row class="mt-05">
                                    <el-col :span="8">已托管数：8 个</el-col>
                                    <el-col :span="8">待托管数：0 个</el-col>
                                    <el-col :span="8">托管率：100%</el-col>
                                </el-row>
                                <el-row class="mt-05">
                                    <el-col :span="8">签单数：6 个</el-col>
                                    <el-col :span="8">完成数：4 个</el-col>
                                    <el-col :span="8">失败数：2 个</el-col>
                                </el-row>
                            </el-col>
                        <el-col :span="12">
                                <el-row><h3>接包信息总览</h3></el-row>
                                <el-row class="mt-15">
                                    <el-col :span="8">信用值：100</el-col>
                                    <el-col :span="8">好评率：80%</el-col>
                                    <el-col :span="8">能力评估：优</el-col>
                                </el-row>
                                <el-row class="mt-05">
                                    <el-col :span="8">项目报名数：10 个</el-col>
                                    <el-col :span="8">接包总金额：1.5  万元</el-col>
                                    <el-col :span="8">签单成功率：30%</el-col>
                                </el-row>
                                <el-row class="mt-05">
                                    <el-col :span="8">签单数：3 个</el-col>
                                    <el-col :span="8">完成数：2 个</el-col>
                                    <el-col :span="8">失败数：10 个</el-col>
                                </el-row>
                        </el-col>
                    </el-row>
                    <el-row class="mt-15">
                        <el-col :span = "12">
                            <el-tag type="warning">优质发包方</el-tag>
                            <el-tag type="warning">成交率高</el-tag>
                            <el-tag type="warning">付款及时</el-tag>
                            <el-tag type="warning">沟通顺畅</el-tag>
                        </el-col>
                        <el-col :span = "12">
                            <el-tag type="warning">种子用户</el-tag>
                        </el-col>
                    </el-row>
                    <div class="text-center mt-50" @click="certificationDetailDialogStatus = false">
                        <el-button >关闭</el-button>
                    </div>
                </div>
            </el-dialog>
        </template>
    </div>
</template>
<script>
    import {
        getAccountList,
        postChangeMobile,
        userUnLock,
        userLock,
        postChangePassword,
        getOperationLog
    } from '@/api/user.js'
    export default {
        data () {
            // 手机号码验证
            var checkPhone = (rule, value, callback) => {
                let pattern = /(13\d|14\d|15\d|17\d|18\d)\d{8}/
                if (value) {
                    if (!pattern.test(value) || value.length !== 11) {
                        return callback(new Error('请输入正确的11位手机号码'))
                    } else {
                        callback()
                    }
                } else {
                    callback()
                }
                // setTimeout(() => {
                //     if (!Number.isInteger(value)) {
                //         console.log('666666')
                //         callback(new Error('请输入正确手机号码'))
                //     } else {
                //         // if (value < 18) {
                //         //     callback(new Error('必须年满18岁'))
                //         // } else {
                //         //     callback()
                //         // }
                //         // if(value.test)
                //         console.log(pattern.test(value))
                //         console.log('123')
                //         callback()
                //     }
                // }, 1000)
            }
            return {
                loading: false,
                loadingLog: false,
                textCenter: false,
                // 帐号表单
                accountSearchForm: {
                    id: '',
                    nickname: '',
                    name: '',
                    mobile: '',
                    status: ''
                },
                // 帐号表单规则
                accountSearchFormRules: {
                    mobile: [{
                        validator: checkPhone,
                        trigger: 'blur'
                    }]
                },
                // 帐号列表
                accountList: [
                // {
                //     id: 'zhouzhijun',
                //     nickname: '破晓的清晨',
                //     name: '张莎莎',
                //     type: 1,
                //     mobile: '15210353215',
                //     status: 1,
                //     registrationTime: '2017-05-01 12:22',
                //     lastLoginTime: '3小时前'
                // }
                ],
                // 翻页
                pagination: {
                    currentPage: 1,
                    pageSize: 1,
                    totalCount: 0,
                    totalPage: 1
                },
                // 修改锁定状态
                changeLockDialogStatus: false,
                changeLockForm: {
                    isLock: '',
                    reason: ''
                },
                changeLockFormRules: {
                    reason: [{
                        required: true,
                        message: '请输入变更原因',
                        trigger: 'blur'
                    },
                    {
                        min: 1,
                        max: 100,
                        message: '长度在 1 到 100 个汉字',
                        trigger: 'blur'
                    }]
                },
                // 修改手机
                changeMobileDialogStatus: false,
                changeMobileForm: {
                    mobile: '',
                    reason: ''
                },
                changeMobileFormRules: {
                    mobile: [{
                        required: true,
                        message: '请输入手机号码',
                        trigger: 'blur'
                    },
                    {
                        validator: checkPhone,
                        trigger: 'blur'
                    }],
                    reason: {
                        required: true,
                        message: '请输入变更原因',
                        trigger: 'blur'
                    }
                },
                // 密码重置
                changePasswordDialogStatus: false,
                changePasswordForm: {
                    id: 0,
                    password: '',
                    reason: ''
                },
                changePasswordFormRules: {
                    password: [{
                        required: true,
                        message: '请输入新密码',
                        trigger: 'blur'
                    },
                    {
                        max: 20,
                        message: '最多输入20位字符',
                        trigger: 'blur'
                    }],
                    reason: {
                        required: true,
                        message: '请输入变更原因',
                        trigger: 'blur'
                    }
                },
                // 查看登录日志
                operationLogDialogStatus: false,
                operationLogForm: {
                    operatorName: '',
                    date: '',
                    pageSize: '',
                    dateEnd: '',
                    dateStart: ''
                },
                operationLogFormRules: {
                    password: [{
                        required: true,
                        message: '请输入手机号码',
                        trigger: 'blur'
                    },
                    {
                        min: 11,
                        max: 11,
                        message: '请输入11位手机号码',
                        trigger: 'blur'
                    }],
                    reason: {
                        required: true,
                        message: '请输入变更原因',
                        trigger: 'blur'
                    }
                },
                // 操作日志
                operationLogList: [
                // {
                //     operatorName: 'zhouzhijun',
                //     createdAt: '2017年1月10日',
                //     client: 'PC',
                //     title: '修改密码',
                //     result: '成功',
                //     content: '原手机号 15210353215 变更为新手机号15210353215'
                // }
                ],
                operationLogPagination: {
                    currentPage: 1,
                    pageSize: 1,
                    totalCount: 0,
                    totalPage: 1
                },
                // 查看认证详情
                certificationDetailDialogStatus: false,
                certificationDetailContent: {
                    id: 123456,
                    userAccountId: 123456,
                    name: '网猫',
                    legalPerson: '猫先生',
                    businessLicenceNum: '123333',
                    businessLicenceImgPath: 'http://dummyimage.com/100x100',
                    expireDate: '20170101',
                    isExpires: 1,
                    applyTime: '20170101',
                    auditorId: '233',
                    auditorName: '蛋蛋',
                    auditorTime: '20170101',
                    auditorStatus: 1
                },
                // 激活的对话框中的数据
                activeDialogData: {
                    id: '',
                    mobile: '',
                    nickname: '',
                    isLock: ''
                }

            }
        },
        methods: {
            // 获取列表数据
            fetchData (data) {
                this.loading = true
                getAccountList(data).then((response) => {
                    this.loading = false
                    if (response.data.code === 0) {
                        let tmp = response.data.data.data
                        for (let i = 0; i < tmp.length; i++) {
                            if (tmp[i].type === 1) {
                                tmp[i].type = ' 个人'
                            } else if (tmp[i].type === 2) {
                                tmp[i].type = '企业'
                            } else if (tmp[i].type === 3) {
                                tmp[i].type = '个人与企业'
                            }
                        }
                        for (let i = 0; i < tmp.length; i++) {
                            if (tmp[i].status === 1) {
                                tmp[i].status = '正常'
                            } else if (tmp[i].status === 2) {
                                tmp[i].status = '冻结'
                            }
                        }
                        this.accountList = response.data.data.data
                        this.pagination = response.data.data
                    } else if (response.data.code === 1) {
                        this.$message('获取用户列表数据失败')
                    }
                }).catch(function (err) {
                    this.loading = false
                    console.log(err)
                })
            },
            // 对话框弹出，填写弹出框的显示数据
            activeDialog (index, data, isActive = false) {
                if (isActive) {
                    this.activeDialogData = data[index]
                } else {
                    this.activeDialogData = {}
                }
            },
            // 关闭对话框
            closeDialog (formName) {
                // this.activeDialogData = {}
                // this.changeLockForm = {}
                // this.changeMobileForm = {}
                // this.changePasswordForm = {}
                // this.operationLogForm = {}
                // this.changeMobileForm.mobile = ''
                this.resetForm(formName)
                // this.resetForm('changeLockForm')
                // this.resetForm('changeMobileForm')
                // this.resetForm('changePasswordForm')
                // this.resetForm('operationLogForm')
                console.log('close')
            },
            // 重置表单
            resetForm (formName) {
                this.$refs[formName].resetFields()
                console.log(formName)
            },
            // 锁定/解锁
            changelock (index, data) {
                this.activeDialog(index, data, true)
                this.changeLockForm.isLock = this.activeDialogData.status === '正常' ? false : this.activeDialogData.status === '冻结'
                this.changeLockDialogStatus = true
            },
            changelockSubmit: function (formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        let data = {}
                        data.id = this.activeDialogData.id
                        data.reason = this.changeLockForm.reason

                        if (!this.changeLockForm.isLock) {
                             // 如果是没有锁定状态，执行解锁
                            userUnLock(data).then((response) => {
                                if (response.data.code === 0) {
                                    this.$message('修改成功')
                                    this.changeLockDialogStatus = false
                                    this.activeDialogData.status = '正常'
                                } else if (response.data.code === 1) {
                                    this.$message('修改失败')
                                }
                            }).catch(function (err) {
                                console.log(err)
                            })
                        } else if (this.changeLockForm.isLock) {
                            // 如果是锁定状态，执行锁定
                            userLock(data).then((response) => {
                                if (response.data.code === 0) {
                                    this.$message('修改成功')
                                    this.activeDialogData.status = '冻结'
                                    this.changeLockDialogStatus = false
                                } else if (response.data.code === 1) {
                                    this.$message('修改失败')
                                }
                            }).catch(function (err) {
                                console.log(err)
                            })
                        }
                    }
                })
            },
            // 手机号变更
            changeMobile (index, data) {
                this.changeMobileDialogStatus = true
                this.activeDialog(index, data, true)
            },
            changeMobileSubmit: function (formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        let data = {}
                        data.id = this.activeDialogData.id
                        let mobile = data.mobile = this.changeMobileForm.mobile
                        data.reason = this.changeMobileForm.reason
                        postChangeMobile(data).then((response) => {
                            if (response.data.code === 0) {
                                this.$message('修改成功')
                                this.activeDialogData.mobile = mobile
                                this.closeDialog('changeMobileForm')
                                this.changeMobileDialogStatus = false
                            } else if (response.data.code === 1) {
                                this.$message('修改失败')
                            }
                        }).catch(function (err) {
                            console.log(err)
                        })
                    }
                })
            },
            // 密码重置
            changePassword (index, data) {
                this.activeDialog(index, data, true)
                this.changePasswordDialogStatus = true
            },
            changePage (currentPage) {
                let data = {
                    pageSize: this.pagination.pageSize,
                    currentPage: currentPage
                }
                this.fetchData(data)
            },
            // 翻页
            changeLogPage (currentPage) {
                let data = {
                    id: this.activeDialogData.id,
                    currentPage: currentPage,
                    pageSize: this.operationLogPagination.pageSize,
                    operatorName: this.operationLogForm.operatorName,
                    date: this.operationLogForm.date
                }
                getOperationLog(data)
            },
            // 修改密码
            changePasswordSubmit: function (formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        let data = {}
                        data.id = this.activeDialogData.id
                        data.password = this.changePasswordForm.password
                        data.reason = this.changePasswordForm.reason
                        postChangePassword(data).then((response) => {
                            if (response.data.code === 0) {
                                this.$message('修改成功')
                                this.closeDialog('changeMobileForm')
                                this.changePasswordDialogStatus = false
                            } else if (response.data.code === 1) {
                                this.$message('修改失败')
                            }
                        }).catch(function (err) {
                            console.log(err)
                        })
                    }
                })
            },
            // 登录日志
            operationLog (index, data) {
                this.activeDialog(index, data, true)
                this.operationLogDialogStatus = true
                let req = {}
                req.id = this.activeDialogData.id
                req.currentPage = 1
                req.pageSize = this.operationLogPagination.pageSize
                req.operatorName = ''
                req.date = ''
                this.fetchoperationLog(req)
            },
            // 获取操作日志
            fetchoperationLog (data) {
                this.loadingLog = true
                data.id = this.activeDialogData.id
                getOperationLog(data).then((response) => {
                    this.loadingLog = false
                    if (response.data.code === 0) {
                        let tmp = response.data.data.data
                        for (let i = 0; i < tmp.length; i++) {
                            if (tmp[i].result === 1) {
                                tmp[i].status = '成功'
                            } else if (tmp[i].status === 2) {
                                tmp[i].result = '失败'
                            }
                        }
                        this.operationLogList = tmp

                        this.operationLogPagination = response.data.data
                        console.log(this.operationLogPagination.totalCount)
                    }
                }).catch(function (err) {
                    this.loadingLog = false
                    console.log(err)
                })
            },

            // 认证详情
            certificationDetail (index, data) {
                this.activeDialog(index, data, true)
                this.certificationDetailDialogStatus = true
            }
        },
        created () {
            this.fetchData()
        }
    }

</script>

<style scoped>
.tableRow{
    height: 38px;
    line-height: 38px;
    line-height: 38px/9;
    text-align: center;
}
.mt-15{
    margin-top: 15px
}
.ml-05{
    margin-left: -5px
}
.mr-25{
    margin-right: 25px;
}

</style>
